package com.yingxue.demo.util;


import com.yingxue.demo.exception.enums.BaseExceptionEnum;
import com.yingxue.demo.vo.resp.ResultVO;

/**
 * @Package: com.company.scaffold.util
 * @Author: Mr.Waves
 * @Date: 2020-03-09 10:59
 * @Description:
 **/
public class ResultVOUtil {
    public static <T> ResultVO success(T data) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(0);
        resultVO.setMessage("操作成功");
        resultVO.setData(data);

        return resultVO;
    }

    public static <T> ResultVO error(BaseExceptionEnum exceptionEnum, T data) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(exceptionEnum.getCode());
        resultVO.setMessage(exceptionEnum.getMessage());
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO error(BaseExceptionEnum exceptionEnum) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(exceptionEnum.getCode());
        resultVO.setMessage(exceptionEnum.getMessage());
        return resultVO;
    }



}
